<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    function getRectangleArea(width, height) {
      return width * height
    }
    console.log("area:", getRectangleArea(20, 30))

    function getCircleArea(radius) {
      return Math.PI * radius * radius
    }
    console.log("ares:", getCircleArea(10))
    console.log("ares:", getCircleArea(25))

    function sumN(n) {
      if (n <= 0) {
        console.log("传入的n有问题")
        return
      }
      // 1~n的数字和
      var result = 0
      for (var i = 1; i < n + 1; i++) {
        result += i
      }
      return result
    }
    console.log("sum:", sumN(5))
    console.log("sum:", sumN(10))
    console.log("sum:", sumN(-10))

  </script>
</body>

</html>